<?php
$db = new Database();

$queries = $db->query("SELECT CONCAT(  'ALTER TABLE ', ws.form_table_name,  ' ADD Editor longtext NOT NULL' ) AS ExecuteTheseSQLCommands FROM tb_workspace ws","array");
foreach ($queries as $value) {
    echo $db->query($value['ExecuteTheseSQLCommands'],"");
}
$queries = $db->query("SELECT CONCAT(  'ALTER TABLE ', ws.form_table_name,  ' ADD Viewer longtext NOT NULL' ) AS ExecuteTheseSQLCommands FROM tb_workspace ws","array");
foreach ($queries as $value) {
    echo $db->query($value['ExecuteTheseSQLCommands'],"");
}
$queries = $db->query("SELECT CONCAT(  'ALTER TABLE ', ws.form_table_name,  ' ADD middleware_process longtext NOT NULL' ) AS ExecuteTheseSQLCommands FROM tb_workspace ws","array");
foreach ($queries as $value) {
    echo $db->query($value['ExecuteTheseSQLCommands'],"");
}
$queries = $db->query("SELECT CONCAT(  'rename table ', LCASE(ws.form_table_name),  ' to ',ws.form_table_name ) AS ExecuteTheseSQLCommands FROM tb_workspace ws","array");
foreach ($queries as $value) {
   $db->query($value['ExecuteTheseSQLCommands']);
}
echo "Done";
?>